/*
* $Id: SettingsVisualComponent.cpp 143 2010-09-09 19:55:18Z volok-aleksej@yandex.ru $
*
* Copyright 2008-2009 by Volokitin Alexey
* All rights reserved
*
*/
#include "Common/include.h"
#include "SettingsVisualComponent.h"

#define PARAMETER_ID	0x1004

CSettingsVisualComponent::CSettingsVisualComponent()
: m_SettingsButton(IDB_PARAMETER, ILanguageManager::GetLanguageManager()->GetString(SETTINGS_CAPTION_ID), DOWN_POS),
m_SettingsWin(){}
CSettingsVisualComponent::~CSettingsVisualComponent(){}

IWnd* CSettingsVisualComponent::GetButtonInMainWindow(){
	if(!IsWindow(m_SettingsButton.m_hWnd)){
		CWnd* pMainFrame = dynamic_cast<CWnd*>(IVisualManager::GetVisualManager()->GetMainWindow());
		m_SettingsButton.Create(CRect(400, 30, 500, 125), pMainFrame, PARAMETER_ID);
	}
	return dynamic_cast<IWnd*>(&m_SettingsButton);
}
void CSettingsVisualComponent::CreateComponentFrame(){
	if(!IsWindow(m_SettingsWin)){
		LPCTSTR strClassName = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW, 
			LoadCursor(GetModuleHandle(NULL), IDC_ARROW), 0,
			LoadIcon(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MAINFRAME)));
		CPoint winCorner(CW_USEDEFAULT, CW_USEDEFAULT);
		m_SettingsWin.Create(strClassName,
			ILanguageManager::GetLanguageManager()->GetString(SETTINGS_CAPTION_ID).c_str(),
			WS_VISIBLE | WS_SYSMENU,
			CRect(winCorner, CSize(700, 500)));
	}
	m_SettingsWin.SetFocus();
}
IWnd* CSettingsVisualComponent::GetComponentFrame(){
	return dynamic_cast<IWnd*>(&m_SettingsWin);
}
void CSettingsVisualComponent::UpdateComponent(){
	if(IsWindow(m_SettingsWin))
		m_SettingsWin.Invalidate(TRUE);
}
void CSettingsVisualComponent::Free(){
	delete this;
}
